package com.spider.ask120.service;

import org.jdiy.core.Args;
import org.jdiy.core.Rs;

public class ArticleService extends BaseService{
	/**
	 * 保存文章
	 * @param article
	 */
	public static void saveArticle(Rs article){
		dao.save(article);
	} 
	/**
	 * 根据文章自增长ID查询
	 * @param id
	 * @return
	 */
	public static Rs getArticleById(String id){
		Rs art = dao.rs(new Args("article", "id="+id));
		return art;
	}
	/**
	 * 更新文章
	 * @param article
	 */
	public static void updateArticle(Rs article){
		dao.save(article);
	}
	/**
	 * 根据文章strID查询
	 * @param id
	 * @return
	 */
	public static Rs getArticleByStrId(String str_id){
		Rs art = dao.rs(new Args("article", "str_id='"+str_id+"' "));
		return art;
	}
	/**
	 * 按条件查询文章
	 * @param ch_id  频道Id
	 * @param title 文章标题
	 * @param pic_path 图片路径
	 * @return 文章
	 */
	public static Rs getArticle(Integer ch_id, String title, String abst){
		Rs art = dao.rs(new Args("article","channel_id="+ch_id+" AND title='"+title+"' AND "
				+" abst='"+abst+"' "));
		return art;
	}
	/**
	 * 按条件查询文章
	 * @param ch_id  频道Id
	 * @param title 文章标题
	 * @param abst 文章简介
	 * @return 文章
	 */
	public static Rs getArticle(String ch_id, String title, String abst){
		Rs art = dao.rs(new Args("article","channel_id="+ch_id+" AND title='"+title+"' AND "
				+" abst='"+abst+"' "));
		return art;
	}
	/**
	 * 按条件查询文章
	 * @param ch_id  频道Id
	 * @param title 文章标题
	 * @param str_id 原文章id
	 * @return 文章
	 */
	public static Rs getArticleByStrId(String ch_id, String title, String str_id){
		Rs art = dao.rs(new Args("article","channel_id="+ch_id+" AND title='"+title+"' AND "
				+" str_id='"+str_id+"' "));
		return art;
	}
	/**
	 * 根据channel_id获取文章列表
	 * @param channel_id
	 * @return
	 */
	public static Rs getArticlesByChannelId(String channel_id) {
		Rs arts = dao.rs(new Args("article","channel_id="+channel_id+" order by id"));
		return arts;
	}
}
